package com.scd.boot.business.sign.controller;

import com.scd.boot.anno.CheckSign;
import com.scd.boot.business.sign.dto.BodyParam;
import com.scd.boot.business.sign.dto.GetParam;
import com.scd.boot.enums.RequestCodeEnum;
import com.scd.boot.model.BaseResponse;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/sign")
@Slf4j
public class SignController {

    @Operation(summary = "post-body参数签名认证")
    @PostMapping(value = "/post/body")
    @CheckSign(timeInterval = 5)
    public BaseResponse<BodyParam> postBody(@RequestBody BodyParam bodyParam) {
        return new BaseResponse<>(RequestCodeEnum.SUCCESS, bodyParam);
    }


    @Operation(summary = "get参数签名认证")
    @PostMapping(value = "/get")
    @CheckSign
    public BaseResponse<GetParam> get(GetParam getParam) {
        return new BaseResponse<>(RequestCodeEnum.SUCCESS, getParam);
    }
}
